package com.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.maps.client.Maps;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;

/*
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class GWTMap implements EntryPoint {

	private static Label msgLabel= new Label();
	private static MapPanel mapPanel;
	
  // GWT module entry point method.
  public void onModuleLoad() {
  
   /*
    * Asynchronously loads the Maps API.
    *
    * The first parameter should be a valid Maps API Key to deploy this
    * application on a public server, but a blank key will work for an
    * application served from localhost.
   */
   Maps.loadMapsApi("ABQIAAAAjTtoIKyTBHLQRcZXULu8SxSEw-roiSZg9-bQ8b8fCKJ7wQZreBR5CNMEVudcMAOxCAfy76_3Jid5hA", "2", false, new Runnable() {
      public void run() {
    	  RootPanel rootPanel = RootPanel.get();
    	  
    	  // Set single marker with no marker listener
    	  
    	  double lat= 26.01;
    	  double lng= -80.09;
    	  double[] lats=new double[1];
    	  double[] lngs=new double[1];
    	  lats[0]= lat;
    	  lngs[0]= lng;
    	  mapPanel=new MapPanel(600, 400, lats, lngs, null, null, null, null);
    	  
    	  
    	  // Set multi marker
    	  /*double lat= 26.01;
    	  double lng= -80.09;
    	  double[] lats=new double[10];
    	  double[] lngs=new double[10];
    	  long[] ids=new long[10];
    	  String[] names=new String[10];
    	  String[] markersLabels=new String[10];
    	  for(int i=0;i<lats.length;i++){
    		  ids[i]= i+1;
    		  names[i]= "marker "+(i+1);
    		  markersLabels[i]= ""+(i+7);
    		  lats[i]= lat;
    		  lngs[i]= lng;
    		  lat+=2;
    		  lng+=2;
    	  }
    	  mapPanel=new MapPanel(600, 400,lats, lngs, ids, names, markersLabels, new MarkerCallBack());
    	  */
    	  
    	  
    	  msgLabel.setSize("100px", "50px");
    	  rootPanel.add(mapPanel,150,150);
    	  
    	  rootPanel.add(msgLabel,20,20);
      }
    });
  }
  
  public static void showMessage(String msg){
	  msgLabel.setText(msg);
  }
  
}